package com.mapper;


import com.mysql.cj.util.StringUtils;
import com.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import javax.annotation.Resource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * dao层抛出异常，让service层去捕获处理
 * @author Administrator
 *
 */
public class UserDaoImpl implements UserDao{

	@Resource
	private SqlSessionTemplate sqlSessionTemplate;


	@Override
	public User getLoginUser(String userCode)
			throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).getLoginUser(userCode);
	}

	@Override
	public int add(User user) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).add(user);
	}

	@Override
	public List<User> getUserList(String userName, int userRole, int currentPageNo, int pageSize) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).getUserList(userName,userRole,currentPageNo,pageSize);
	}

	@Override
	public int getUserCount(String userName, int userRole) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).getUserCount(userName,userRole);
	}

	@Override
	public int deleteUserById(Integer delId) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).deleteUserById(delId);
	}

	@Override
	public User getUserById(String id) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).getUserById(id);
	}

	@Override
	public int modify(User user) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).modify(user);
	}

	@Override
	public int updatePwd(int id, String pwd) throws Exception {
		return sqlSessionTemplate.getMapper(UserDao.class).updatePwd(id,pwd);
	}
}
